package com.itheima.ums.controller;

import cn.hutool.core.collection.CollUtil;
import com.itheima.mall.pojo.MemberLevel;
import com.itheima.mall.vo.PageResult;
import com.itheima.ums.mapper.UmsMemberLevelMapper;
import com.itheima.ums.service.UmsMemberLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/memberLevel")
public class UmsMemberLevelController {

    @Autowired
    private UmsMemberLevelService umsMemberLevelService;

    /**
     * 查询所有会员等级
     * @param defaultStatus
     * @return
     */
    @GetMapping("/list")
    public ResponseEntity list(Long defaultStatus) {

        List<MemberLevel> list = umsMemberLevelService.list(defaultStatus);
        if (CollUtil.isEmpty(list)) {
            return ResponseEntity.ok("ok");
        }
        return ResponseEntity.ok(list);

    }
}
